package omarfouad.utils {
	
	/**
	 * TimeUtil Class
	 * 
	 * A utility class used to calculate the time difference between two dates
	 * returned by the Date() constructor
	 * 
	 * Coded By Omar Fouad
	 * www.omar-fouad.net
	 * omarfouad.net@gmail.com
	 */
	  
	 public class TimeUtil {
		
		private static var milliday:Number = 86400000;
		private static var millihour:Number = 3600000;
		private static var millimin:Number = 60000;
		private static var millisec:Number = 1000;
		
		private static var OutputObject:Object = new Object();
		
		public static function getDifference(DateFrom:Date, DateTo:Date):Object {
			
			var difference:Number = DateTo.getTime() - DateFrom.getTime();
			var days:Number = Math.floor(difference / milliday);
			var difference:Number = difference % milliday;
			var hours:Number = Math.floor(difference / millihour);
			var difference:Number = difference % millihour;
			var minutes:Number = Math.floor(difference / millimin);
			var difference:Number = difference % millimin;
			var seconds:Number = Math.floor(difference / millisec);
			
			OutputObject.seconds = seconds;
			OutputObject.minutes = minutes;
			OutputObject.hours = hours;
			OutputObject.days = days;
			
			return OutputObject;
		}
	}
}
